import java.util.Random;
import java.util.Scanner;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class ToneScissorClothImpl implements ToneScissorCloth {
    @Override
    public int gamestander(int person, int computer) {

        int result=-1;//记录是谁赢1是人赢 2是电脑赢0是平局
        Scanner sc = new Scanner(System.in);

            String enter = sc.next();  //接收用户输入的字符
            int randomNumber = new Random().nextInt(3) + 1;
            if (enter.equals("剪刀")) {    //判断用户输入的字符
                if (randomNumber == 1) {    //判断谁输谁赢
                    log.info("电脑出的是剪刀");
                    log.info("平");
                    result=0;
                } else if (randomNumber == 2) {
                    log.info("电脑出的是石头");
                    log.info("你输了");
                    result=2;
                } else if (randomNumber == 3) {
                    log.info("电脑出的是布");
                    log.info("你赢了");
                    result=1;
                }
            } else if (enter.equals("石头")) {
                if (randomNumber == 1) {
                    log.info("电脑出的是剪刀");
                    log.info("你赢了");
                    result=1;
                } else if (randomNumber == 2) {
                    log.info("电脑出的是石头");
                    log.info("平");
                    result=0;
                } else if (randomNumber == 3) {
                    log.info("电脑出的是布");
                    log.info("你输了");
                    result=2;
                }
            } else if (enter.equals("布")) {
                if (randomNumber == 1) {
                    log.info("电脑出的是剪刀");
                    log.info("你输了");
                    result=2;
                } else if (randomNumber == 2) {
                    log.info("电脑出的是石头");
                    log.info("你赢了");
                    result=1;
                } else if (randomNumber == 3) {
                    log.info("电脑出的是布");
                    log.info("平");
                    result=0;
                }
            } else {
                log.info("输入错误！");
                result=-1;//输入错误对局不算即i不增加
            }

      return result;
    }
}
